/**
 * @file
 * @author  michal.nezerka@gmail.com
 */

#include <iostream>
#include <wx/statbox.h>
#include <wx/stattext.h>
#include <wx/valgen.h>

#include "latlondlg.h"

namespace wildwood
{

BEGIN_EVENT_TABLE(LatLonDlg, wxDialog)
    EVT_CLOSE(LatLonDlg::OnClose)
END_EVENT_TABLE()

LatLonDlg::LatLonDlg(wxDialog *dlg, const wxString &title, const double lat, const double lon)
    : wxDialog(dlg, -1, title), mLat(lat), mLon(lon)
{
    SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY | wxRESIZE_BORDER);

    wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);

    // create buttons
    wxSizer* btnSizer = CreateButtonSizer(wxOK | wxCANCEL);

    //wxNotebook* m_bookCtrl = new wxNotebook(this, wxID_ANY); //, wxDefaultPosition, wxDefaultSize, wxWS_EX_VALIDATE_RECURSIVELY);

    //wxPanel* pageGeneral = CreateGeneralPage(m_bookCtrl);
    //m_bookCtrl->AddPage(pageGeneral, _("General"), true);

    //mainSizer->Add(m_bookCtrl, 0, wxALL | wxEXPAND, 5);

    // latitude
    //wxString lat;

    wxBoxSizer *latSizer = new wxBoxSizer( wxHORIZONTAL );
    mainSizer->Add(new wxStaticText(this, wxID_ANY, wxT("Latitude:")), 0, wxALL | wxEXPAND, 3);
    latSizer->Add(new wxTextCtrl(
        this,
        wxID_ANY,
        wxEmptyString,
        wxDefaultPosition,
        wxDefaultSize,
        0,
        wxGenericValidator(&mLat)),  1, wxALL | wxEXPAND | wxCENTER);
    mainSizer->Add(latSizer);

    // longitude
    //wxString lon;

    wxBoxSizer *lonSizer = new wxBoxSizer( wxHORIZONTAL );
    mainSizer->Add(new wxStaticText(this, wxID_ANY, wxT("Longitude:")), 0, wxALL | wxEXPAND, 3);
    lonSizer->Add(new wxTextCtrl(
        this,
        wxID_ANY,
        wxEmptyString,
        wxDefaultPosition,
        wxDefaultSize,
        0,
        wxGenericValidator(&mLon)),  1, wxALL | wxEXPAND | wxCENTER);
    mainSizer->Add(lonSizer);

    // static line
    wxStaticLine * staticLine1 = new wxStaticLine(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL);
    mainSizer->Add(staticLine1, 0, wxALL | wxEXPAND, 5);

    // sizing stuff
    mainSizer->Add(btnSizer, 0, wxALL, 3);

    this->SetSizer(mainSizer);
    this->Layout();
    mainSizer->Fit(this);
}

LatLonDlg::~LatLonDlg() { }

void LatLonDlg::OnClose(wxCloseEvent &event)
{
    Destroy();
}

bool LatLonDlg::TransferDataToWindow()
{
    bool result = wxDialog::TransferDataToWindow();

    return result;
}

bool LatLonDlg::TransferDataFromWindow()
{
    bool result = wxDialog::TransferDataFromWindow();

    return result;
}

} // namespace
